#ifndef DATABASEDIALOG_H
#define DATABASEDIALOG_H

#include <QDialog>

namespace Ui {
class DatabaseDialog;
}

class DatabaseModel;

class DatabaseDialog : public QDialog
{
    Q_OBJECT

public:
    explicit DatabaseDialog(QWidget *parent = 0);
    ~DatabaseDialog();

    void updateToday(const QTime& i_begin,
                     const QTime& i_break);

    void updateTodaysEnd(int i_msecsToAdd);
    bool hasError() const { return m_hasError; }

private slots:
    void loadTisowareData();
    void showTotalWorkTime();

private:
    bool initDb();
    bool createDb();
    bool upgradeDb();
    void initTisowareDb();

    static bool upgradeDb0to1();
    static bool upgradeDb1to2();
    static bool upgradeDb2to3();
    static QString secondsToString(int i_seconds);

private:
    Ui::DatabaseDialog *ui;
    DatabaseModel* m_pModel;
    bool m_hasError;

    static const int DB_VERSION = 3;
    static const QString TABLE_NAME;
};

#endif // DATABASEDIALOG_H
